package com.imooc.service.impl;

import com.imooc.dao.TestRepository;
import com.imooc.domain.Test;
import com.imooc.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Description:
 * Author: gzj
 * Date: 2024/11/8 10:40
 */
@Service
@Transactional
public class TestServiceImpl implements TestService {

    @Autowired
    private TestRepository repository;

    @Override
    public void insert(Test test) {
        repository.save(test);
    }

    @Override
    public void update(Test test) {
        repository.saveAndFlush(test);
    }

    @Override
    public void delete(Test test) {
        repository.deleteById(test.getId());
    }

    @Override
    public List<Test> list(Test test) {
        return repository.findAll();
    }
}
